/**
 * 定义全局变量
 */
var G_WEBBASE = "http://106.14.139.5:7014/GZ/Docpre/GetDTfollowupRecordPC?docguid=";
//入参
var page=0; //页码
var size=3; //每页显示条数
var docguid="1EB9C005C210E8BFE050007F01002A27"; //患者guid

$(function(){

   // dropload
    var dropload = $('.content').dropload({
        domDown : {
            domClass   : 'dropload-down',
            domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData  : '<div class="dropload-noData">暂无数据</div>'
        },
    	
        scrollArea : window,
        loadDownFn : function(me){
            page++;
            //alert(page);
            // 拼接HTML
            var result = '';
            $.ajax({
                type: 'POST',
                url: 'http://106.14.139.5:7014/GZ/Docpre/GetDTfollowupRecordPC?docguid='+docguid+'&pageNo='+page+'&pageSize='+size,
                //async: false,
                timeout: 8000,
                success: function(data){
                	data = data.trim();
				   data = data.replace(/\n/g, '');
				   
                    var regJson = JSON.parse(data);
                    if(regJson.code == 000){
                        for(var i = 0; i < regJson.data.parameterType.length; i++){
                        	
                        	//DOM取数据库数据
                        	var followdatetime = regJson.data.parameterType[i].followdatetime;
                        	var name = regJson.data.parameterType[i].name;
                        	var department = regJson.data.parameterType[i].department;
                        	var followoption = regJson.data.parameterType[i].followoption;
                        	console.log(followoption);
                        	
                        result += `<div class="opacity" style="padding: 0 30px;background: #fff;">
					      <p class="">
					        <span class="">日期:</span>
					        <span class="">${followdatetime}</span>
					      </p>
					      <p class="">
					        <span class="">医生:</span>
					        <span class=""> ${name} </span>
					      </p>
					       <p class="">
					        <span class="">科室：</span>
					        <span class="">${department}</span>
					      </p>
					      <p style="padding-bottom: 10px;">
					        <span class="">随访内容：</span>
					        <span style="width: 77%;margin-top: -3px;">
						        <i  style="margin-top:5px;border: 1px solid #1097E1;font-style: normal;display: inline-block;height: 25px;line-height: 24px;padding: 0 8px;border-radius: 10px;color: #1097E1;margin-left: 5px;font-size: 13px;">${followoption}</i>
					       </span>
					      </p>
				    </div>
				     <p style="margin-top: 13px;background: #fff;padding-top: 11px;padding-bottom: 11px;padding-left: 30px;text-align: right;cursor:pointer;">
			    		<span style="color: #00A8EC;">进入随访诊室</span>
						<i class="glyphicon glyphicon-menu-right" style="margin-right: 25px;height: 40px;line-height: 40px;color: #E2E2E2;"></i>
			       </p>`;
                        }
                         
                    // 如果没有数据
                    }else{
                        // 锁定
                        me.lock();
                        // 无数据
                        me.noData();
                        //alert("暂无数据");
                        $('#dataimg').css('display','block');
                       
                    }
                    // 为了测试，延迟1秒加载
                  setTimeout(function(){
                      // 插入数据到页面，放到最后面
                      $('.lists').append(result);
                      // 每次数据插入，必须重置
                      me.resetload();
                      //$('.dropload-load').text('暂无数据');
                  },1000);
                },
                error: function(xhr, type){
                    alert('Ajax error!');
                    // 即使加载出错，也得重置
                    me.resetload();
                    
                }
            });
        }
    });
});
